<!--************************************************************************************************-->
<!-- < Group.php >                                                                               -->
<!-- Copyright (c) 2012-2013 San Yat-sun University School of Software                              -->
<!-- Modifier: Tianjiao Li                                                                 -->
<!-- Stu : 10389129                                                                                 -->
<!-- Date: 2012-01-01                                                                               -->
<!-- Destription :                                                           -->
<!--                                                                                                -->
<!-- Version : 2.1                                                                                  -->
<!--************************************************************************************************-->

<?php
	include_once("../persistent/BaseObject.php");
	
	class Comment extends BaseObject
	{
		public $Content;
		public $Username;
		public $Bookname;
		//public $Thesisname;
		public $date;
		
		public function __construct($d)
		{
			$this->tableName = "Comments";
			parent::__construct($d);	
		}		
		
		public function findValueByUsername($Username)
		{
			$con = $this->openDB();
			
			// 找出Username的条目
			$sql = "SELECT * FROM $this->tableName
			WHERE Username = '$Username'";
			
			return mysql_fetch_array($this->startSQL($sql,$con));
		}
		
		public function findValueByBookname($Bookname)
		{
			$con = $this->openDB();
			
			// 找出Username的条目
			$sql = "SELECT * FROM $this->tableName
			WHERE Bookname = '$Bookname'";
			
			return $this->startSQL($sql,$con);
		}	
		
		public function findAllValue()
		{
			$con = $this->openDB();
			
			// 找出Username的条目
			$sql = "SELECT * FROM $this->tableName";
			
			return mysql_fetch_array($this->startSQL($sql,$con));
		}
		
		public function findValueByThesisname($Thesisname)
		{
			$con = $this->openDB();
			
			// 找出Username的条目
			$sql = "SELECT * FROM $this->tableName
			WHERE Thesisname = '$Thesisname'";
			
			return $this->startSQL($sql,$con);
		}
		
		// find all the comments of the current user
		public function findCommentlistByUsername($Username)
		{
			$con = $this->openDB();
			
			$sql = "SELECT * FROM $this->tableName
			WHERE Username = '$Username'";
			
			return $this->startSQL($sql,$con);
		}
		
		// find the first N Comments of the current user
		public function findNCommentsByUsername($Username, $N)
		{
			$con = $this->openDB();
			
			$sql = "SELECT * FROM $this->tableName
			WHERE Username = '$Username'
			LIMIT $N";
			
			return $this->startSQL($sql,$con);
		}
		
	}

?>
